import re
import pandas as pd

# 文件路径（确保路径正确）
file_path = """The Power of Persistence in Achieving Goals

Persistence is often hailed as one of the most valuable traits a person can possess, and for good reason. It is the driving force that turns aspirations into reality, enabling individuals to overcome obstacles, learn from failures, and ultimately succeed in their endeavors. In a world where instant gratification is increasingly sought after, the ability to persist through challenges has become more important than ever.

Consider the story of Thomas Edison, whose invention of the light bulb is a classic example of persistence. It is widely reported that Edison failed thousands of times before finally creating a functional incandescent bulb. When asked about these failures, he famously remarked, “I have not failed. I’ve just found 10,000 ways that won’t work.” This mindset—viewing setbacks as opportunities for learning rather than reasons to quit—is the essence of persistence. Edison’s success was not due to sudden inspiration but to his unwavering commitment to his goal, even in the face of repeated disappointment.

Persistence is equally crucial in everyday life, not just in the realm of scientific invention. Students facing difficult subjects, athletes striving to improve their performance, and professionals working toward career milestones all rely on persistence to achieve their objectives. For instance, a student struggling with mathematics may feel tempted to give up after receiving poor grades on several tests. However, by persisting—seeking help from teachers, practicing daily, and refusing to be discouraged by temporary failures—they can gradually improve their understanding and performance.

One of the key reasons persistence is so effective is that it allows individuals to gain valuable experience and knowledge over time. Each attempt, even if unsuccessful, provides insights that can be used to refine strategies and approaches. A writer, for example, may draft a manuscript dozens of times before it is ready for publication. Each revision, informed by previous mistakes and feedback, brings the work closer to perfection. Without persistence, the writer might abandon the project after the first few drafts, never realizing its full potential.

Persistence also builds resilience, the ability to bounce back from adversity. Life is full of unexpected challenges, and those who persist develop the mental toughness to handle setbacks without losing motivation. This resilience extends beyond the immediate goal, benefiting various areas of life. A person who persists through a difficult job search, for example, not only increases their chances of finding employment but also develops coping skills that will serve them well in future challenges.

Critics may argue that persistence can sometimes lead to stubbornness, causing individuals to cling to unachievable goals. However, there is a crucial difference between persistence and stubbornness. Persistence involves adaptability—being willing to adjust methods while staying committed to the ultimate goal. Stubbornness, on the other hand, involves rigidly sticking to a single approach, even when it is clear that it is not working. Successful people know when to pivot their strategies while maintaining their focus on the end result.

In today’s fast-paced world, where information is readily available and changes occur rapidly, persistence is more important than ever. Many of the most significant achievements in history—from technological innovations to social movements—took years, if not decades, of sustained effort. Consider the fight for civil rights in the United States, which involved countless individuals persisting through decades of discrimination, violence, and setbacks before significant progress was made. Their unwavering commitment to justice ultimately led to landmark legislation and societal change."""

# 读取文件内容
with open(file_path, encoding='utf-8') as fin:
    content = fin.read()

# 分割单词（修正正则表达式）
words = re.split(r"[\s.()\-?]+", content)
words = [word for word in words if word]  # 过滤空字符串

# 输出词频统计
print(pd.Series(words).value_counts()[:20])